$(document).ready(function () {
    const urlParams = new URLSearchParams(window.location.search);
    const number = urlParams.get('number');
    $("#edit").click(function (e) {
        e.preventDefault();
        const Name = $("input[name='name']").val();
        const Author = $("input[name='author']").val();
        const Publisher = $("input[name='publisher']").val();
        const Price = $("input[name='price']").val();
        const Quantity = $("input[name='quantity']").val();
        $.ajax({
            url: "BookAddServlet",
            method: "post",
            data: {
                number: number,
                name: Name,
                author: Author,
                publisher: Publisher,
                price: Price,
                quantity: Quantity

            },
            dataType: "json",
            success: function (result) {
                if (result.msg === "success") {
                    window.location.href = "AssistantBookList.html";
                    console.log(result.message);
                } else {
                    $('#message').text('修改失败，请稍后重试');
                }
            },
            error: function () {
                $('#message').text('服务未连接，请稍后重试');
            }
        });
    });
});
